package P5;

import java.io.*;
import java.net.*;


/**
 * 5.2完成用户登录
 * 5.2.2客户端的代码：
 */
public class ClientLogin {
    public static void main(String[] args) {
        try {
            Socket socket = new Socket("localhost", 9999);

            BufferedReader userInput = new BufferedReader(new InputStreamReader(System.in));
            BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            PrintWriter out = new PrintWriter(socket.getOutputStream(), true);

            System.out.print("Enter username and password (comma separated): ");
            String inputLine = userInput.readLine();
            out.println(inputLine);

            System.out.println("Server response: " + in.readLine());

            userInput.close();
            in.close();
            out.close();
            socket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}